﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using CFSystem.JXC.Model;
using CFSystem.JXC.IDAL;
using CFSystem.JXC.DALFactory;
using CFSystem.JXC.AccessDAL;

namespace CFSystem.JXC.BLL
{
    public class Unit
    {
        // Get an instance of the Category DAL using the DALFactory
        // Making this static will cache the DAL instance after the initial load
        private static readonly IUnit dal = DALFactory.DataAccess.CreateUnit();

        public Unit()
        { }
        /// <summary>
        /// Method to get all categories
        /// </summary>										
        /// <returns>Generic List of CategoryInfo</returns>	   		
        public IList<UnitInfo> GetUnits()
        {
            return dal.GetUnits();
        }
        
         /// <summary>
         /// insert Unit into db.
         /// </summary>
         /// <param name="UnitName"></param>
        public void Insert(string UnitName)
        {
            //check name
            
            //insert
            dal.InsertUnit(UnitName);
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="UnitID"></param>
        public void Delete(int UnitID)
        {
            dal.DelUnitByID(UnitID);
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="UnitID"></param>
        /// <param name="updValue"></param>
        public void Update(int UnitID, string updValue)
        {
            dal.UpdateUnitByID(UnitID, updValue);
        }
    }
}
